<extend name="Public/base"/>

<!-- 子導航 -->
<block name="sidebar">
    <include file="Article/sidemenu" />
  
</block>
<block name="style">
<link href="__STATIC__/Alayer/layer.css" rel="stylesheet" type="text/css"/>
</block>

<block name="body">

	<!-- 標題 -->
	<div class="main-title">
		<h2>
		會員中心
		</h2>
	</div>

	<!-- 按鈕工具欄 -->
	<div class="cf">
		<div class="fl">
			<div class="btn-group">
			
                            <button class="btn document_add" url="{:U('Member/adds')}">新 增</button>
                            <button class="btn ajax-post confirm showlayer">通知</button> 
				
                            
                            <div class="search-form fr cf">
			
                                <select name="CourseSelect" onchange="CourseChange(this.options[this.options.selectedIndex].value)">
                                    <option value="">课程课程</option>
                                    <volist name="AppList" id="Nav">

                                        
                                        <option value="{$Nav['title']}">{$Nav['title']}</option>          
                                    </volist>  
                                </select>
			</div>
			</div>
        
			<input type="hidden" class="hide-data" name="cate_id" value="{$cate_id}"/>
			<input type="hidden" class="hide-data" name="pid" value="{$pid}"/>
		
			
		
		</div>

		<!-- 高級搜索 -->
		<div class="search-form fr cf">
			<div class="sleft">
				<div class="drop-down">
					<span id="sch-sort-txt" class="sort-txt" data="{$status}"><if condition="get_status_title($status) eq ''">所有<else/>{:get_status_title($status)}</if></span>
					<i class="arrow arrow-down"></i>
					<ul id="sub-sch-menu" class="nav-list hidden">
						<li><a href="javascript:;" value="">所有</a></li>
						<li><a href="javascript:;" value="1">正常</a></li>
						<li><a href="javascript:;" value="0">禁用</a></li>
						<li><a href="javascript:;" value="2">待審核</a></li>
					</ul>
				</div>
				<input type="text" name="title" class="search-input" value="{:I('title')}" placeholder="請輸入標題文檔">
				<a class="sch-btn" href="javascript:;" id="search" url="{:U('article/index','pid='.I('pid',0).'&cate_id='.$cate_id,false)}"><i class="btn-search"></i></a>
			</div>
            <div class="btn-group-click adv-sch-pannel fl">
                <button class="btn">高 級<i class="btn-arrowdown"></i></button>
                <div class="dropdown cf">
                	<div class="row">
                		<label>更新時間：</label>
                		<input type="text" id="time-start" name="time-start" class="text input-2x" value="" placeholder="起始時間" /> -
                		<input type="text" id="time-end" name="time-end" class="text input-2x" value="" placeholder="結束時間" />
                	</div>
                	<div class="row">
                		<label>創建者：</label>
                		<input type="text" name="nickname" class="text input-2x" value="" placeholder="請輸入用戶名">
                	</div>
                </div>
            </div>
		</div>
	</div>

	<!-- 數據表格 -->
    <div class="data-table">
		<table>
            <!-- 表頭 -->
            
            <thead>
                <tr>
                        <th class="row-selected row-selected">
                            <input class="check-all" type="checkbox">
                        </th>
                   
                            <th>編號</th>
                            <th>用戶名</th>
                            <th>卡號</th>
                            <th>更新時間</th>
                            <th>操作</th>
                                                       
                   
                    </tr>
            </thead>

            <!-- 列表 -->
            <tbody>
               <volist name="list" id="list">
                        <tr>
                            <td><input class="ids" type="checkbox" value="{$list['id']}" name="ids[]"></td>
                            <td>{$list['id']}</td>
                            <td><a href='{:U("Member/edits",array("id"=>$list["id"]))}'>{$list['ccount']}</a></td>    
                            <td>{$list['uids']}</td>    
                              <td>{$list['create_time']|date='y-m-d',###}</td>  
                               <td><a href='{:U("Member/edits",array("id"=>$list["id"]))}'>編輯</a>
                               <a href="{:U('Member/del?id='.$list['id'])}" class="confirm ajax-get">删除</a>
                               </td>     
                        </tr>
                 </volist> 
            </tbody>
        </table>
	</div>

           <!--彈出層-->
  <div class="layer_bg">     
    <div id="layer" class="layer">
    <script src="__STATIC__/uploadify/jquery.Huploadify.js" type="text/javascript"></script>    
     <div class="form-item cf">
       <div class="controls" style="margin-bottom: 10px">
                        <label class="textarea input-large">
                            <textarea id="EContent" name="EContent"></textarea>
                                </label>                    </div>
                </div>
       <div class="form-item cf">
       <div class="controls" style="margin-bottom: 10px">
        支持格式：jpg,gif,png,jpeg图片上傳(後續名請使用小寫)       
       {:hook('UploadImages', array('name'=>'pic','value'=>''))}
       </div>
       </div> 
       <div class="form-item cf">

  <div class="controls">
         支持格式：excel,word,txt文檔上傳(後續名請使用小寫)                                                      
									<input type="hidden" name="{$field.name}" value="{:think_encrypt(json_encode(get_table_field($data[$field['name']],'id','','File')))}"/>
									<div class="upload-img-box">
										<present name="data[$field['name']]">
											<div class="upload-pre-file"><span class="upload_icon_all"></span>{$data[$field['name']]|get_table_field=###,'id','name','File'}</div>
										</present>
									</div>              <div id="upload_file_{$field.name}"></div>
								</div>
								<script type="text/javascript">
								//上傳圖片
							    /* 初始化上傳插件 */
								$("#upload_file_{$field.name}").Huploadify({
                                                                "auto":true,
                                                                "buttonText"      : "上传附件",
                                                                "multi":true,
                                                                "fileObjName"    : "download",
                                                                "width"           : 120,
                                                                "removeTimeout"   : 1,
							        "uploader"        : "{:U('File/upload',array('session_id'=>session_id()))}",
							  
								onUploadComplete:function (file, data){
								var data = $.parseJSON(data);
							        if(data.status){
                                                      
							        	var name = "{$field.name}";
							        	$("input[name="+name+"]").val(data.data);
							        	$("input[name="+name+"]").parent().find('.upload-img-box').html(
							        		"<div class=\"upload-pre-file\"><span class=\"upload_icon_all\"></span>" + data.info + "<a href='#' class='del'>刪除</a></div>"
							        	);
							        } else {
							        	updateAlert(data.info);
							        	setTimeout(function(){
							                $('#top-alert').find('button').click();
							                $(that).removeClass('disabled').prop('disabled',false);
							            },1500);
							        }
							    }
                                                              });
                                                              $(document).on('click','.del',function(){
                                                                  $(this).parents().siblings('input').attr('value','');
                                                                  $(this).parent().remove();
                                                               
                                                              });
								</script>
       <button style="float: right" class="btn btn-small" onclick="layer_close()">關閉</button>
    
        <button id="layer-post" style="float: right; background: #ff0000"  class="btn confirm" target-form="ids">發送</button>   
    </div>
  </div> 
      <!--彈出層 end-->  
      
	<!-- 分頁 -->
    <div class="page">
        {$_page}
    </div>
</div>

</block>
<block name="script">
<script src="__STATIC__/Alayer/layer.js" type="text/javascript"></script>    

<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
$(function(){
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
		var status = $("#sch-sort-txt").attr("data");
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
		if(status != ''){
			query += 'status=' + status + "&" + query;
        }
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});

	/* 狀態搜索子菜單 */
	$(".search-form").find(".drop-down").hover(function(){
		$("#sub-sch-menu").removeClass("hidden");
	},function(){
		$("#sub-sch-menu").addClass("hidden");
	});
	$("#sub-sch-menu li").find("a").each(function(){
		$(this).click(function(){
			var text = $(this).text();
			$("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
			$("#sub-sch-menu").addClass("hidden");
		})
	});

	//只有壹個模型時，點擊新增
	$('.document_add').click(function(){
		var url = $(this).attr('url');
		if(url != undefined && url != ''){
			window.location.href = url;
		}
	});

	//點擊排序
	$('.list_sort').click(function(){
		var url = $(this).attr('url');
		var ids = $('.ids:checked');
		var param = '';
		if(ids.length > 0){
			var str = new Array();
			ids.each(function(){
				str.push($(this).val());
			});
			param = str.join(',');
		}

		if(url != undefined && url != ''){
			window.location.href = url + '/ids/' + param;
		}
	});

    //回車自動提交
    $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
            $("#search").click();
        }
    });

    $('#time-start').datetimepicker({
        format: 'yyyy-mm-dd',
        language:"zh-CN",
	    minView:2,
	    autoclose:true
    });

    $('#time-end').datetimepicker({
        format: 'yyyy-mm-dd',
        language:"zh-CN",
	    minView:2,
	    autoclose:true
    });
})
$('#layer-post').click(function(){
     var con = $('#EContent').val();
//     var title = $("input[name='ECtitle']").val();
    var fileid = $('.files').val();
     var pic = $('.pic').val();
     var ids=[];
      if ($("input[type=checkbox]:checked").size() == 0) 
      { 
          updateAlert('请至少选择一条记录进行通知操作！', 'alert-error');  
          setTimeout(function () {
          location.reload();
          }, 1500);
           return false;
      }
      if($('#EContent').val()=="")
      {
           updateAlert('內容不能為空', 'alert-error');
           setTimeout(function () {
           location.reload();
           }, 1000);
           return false;
      }
      if($('#ECtitle').val() == ""){
          updateAlert('标题不能为空', 'alert-error');
           setTimeout(function () {
           location.reload();
           }, 1000);
           return false;
      }
     $('.ids').each(function(){
        if($(this).is(":checked"))
        {
            ids.push($(this).val());
        }
     });
     updateAlert('發送中', 'alert-success');
     $.post('{:U("Article/setNoticeStatus",array("status"=>3))}',{EC:con,pic,file_id:fileid,ids},
     function (data) { 
 

     updateAlert('通知成功', 'alert-success');
     setTimeout(function () {
     location.reload();
         }, 1500);
    });
 });        
 function CourseChange(index){
     location.href="?CourseSelect="+index;
 }
</script>
</block>